package main

func sumOfTheDigitsOfHarshadNumber(x int) int {
	sum := 0
	v := x
	for v > 0 {
		sum += v%10
		v /= 10
	}
	if x%sum == 0 {
		return sum
	}
	return -1
}

func main() {
	println(sumOfTheDigitsOfHarshadNumber(18))
	println(sumOfTheDigitsOfHarshadNumber(18))
}